﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HardToolApp.Model
{
    internal class IICSlaveModel: Communicate
    {
        private byte _addr = 0xa0;
        public byte addr { get { return _addr; }set { _addr = value; } }
        private string _addrStr;
        public string addrStr
        {
            get { return _addr.ToString("X2"); }
            set { SetProperty(ref _addrStr, value); _addr = Convert.ToByte(_addrStr, 16); }
        }
        private UInt16 _timeout = 1000;
        public UInt16 timeout { get { return _timeout; } set { SetProperty(ref _timeout, value); } }
        byte _readLen = 4;
        public byte readLen { get { return _readLen; } set { SetProperty(ref _readLen, value); } }
        public IICSlaveModel() : base(CommCmd.COMM_IIC_SLAVE) { }


        public override string ToString()
        {
            switch (subCmd)
            {
                case 1:
                    return "改变IIC从机参数->从机地址:" + addrStr + "\n";
                case 2:
                    return "IIC从机写入数据->" + sendBytes + "\n";
                case 3:
                    return "IIC从机读取"+readLen.ToString()+"个数据" + "\n";
                default:
                    return "未知命令" + "\n";
            }
        }
    }
}
